import { defineStore } from 'pinia'
import { ref } from 'vue'

// 定义 Store
export const useVideoStore = defineStore(
  'video',
  () => {
    //视频信息
    const video1 = ref([])
    const video2 = ref([])
    const video3 = ref([])
    //音乐
    const music = ref('')
    const title = ref('')
    const copy = ref('')
    const label = ref('')
    const poi = ref('')
    //保存用户信息
    const setVideo1 = (val) =>{
      video1.value = val
    }
    const setVideo2 = (val) =>{
      video2.value = val
    }
    const setVideo3 = (val) =>{
      video3.value = val
    }
    const setMusic = (val) =>{
      music.value = val
    }
    const setCopy = (val) =>{
      copy.value = val
    }
    const setTitle = (val) =>{
      title.value = val
    }
    const setLabel = (val) =>{
      label.value = val
    }
    //保存用户选择店铺的ID
    const setPoi = (val) => {
      poi.value = val
    }
    // 清理店铺信息，删除时使用
    const clearVideo = () => {
      video1.value = []
      video2.value = []
      video3.value = []
      music.value = null
      copy.value = null
      label.value = null
      title.value = null
      poi.value = null
    }

    // 记得 return
    return {
      video1,
      video2,
      video3,
      music,
      title,
      label,
      copy,
      poi,
      setVideo1,
      setVideo2,
      setVideo3,
      setMusic,
      setCopy,
      setTitle,
      setLabel,
      setPoi,
      clearVideo
    }
  },
  // TODO: 持久化
  {
    persist: true,
  },
)